package com.yanjr.modules.cms.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.yanjr.common.persistence.BaseDaoImpl;
import com.yanjr.common.utils.DateUtil;
import com.yanjr.common.utils.StringUtils;
import com.yanjr.modules.cms.dao.ArticleDao;
import com.yanjr.modules.cms.entity.Article;

@Repository("articleDao")
public class ArticleDaoImpl extends BaseDaoImpl<Article> implements ArticleDao {

	@Override
	public List<Article> findByIdIn(String[] ids) {
		String sql = "select * from cms_article where id in ('" + StringUtils.join(ids, "','") + "')";
		return super.findList(sql);
	}
	
	@Override
	public int updateHitsAddOne(String id) {
		String sql = "update cms_article set hits=hits+1 where id=?";
		return super.update(sql, id);
	}

	@Override
	public int updateExpiredWeight() {
		String sql = "update cms_article set weight=0 where weight>0 and weight_date<?";
		return super.update(sql, DateUtil.getDateTime());
	}

	

}
